//
//  AddRoomCellTableViewCell.m
//  AILock
//
//  Created by 谭亚明 on 2020/7/7.
//  Copyright © 2020 tym. All rights reserved.
//

#import "AddRoomCell.h"
#import "Masonry.h"
#import "UIImageView+YPImage.h"
@interface AddRoomCell()
{
    BOOL        _isSelect;
}
@property(nonatomic,weak)  UIImageView *headIamge;
@property(nonatomic,weak)  UILabel *mobile;
@property(nonatomic,weak) UIImageView *appImage;
@end

@implementation AddRoomCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initUI];
    }
    return self;
}

- (void)setchecked:(BOOL)checked{
    _isSelect = checked;
    
}

-(void)initUI{
    
    UIImageView *head = [[UIImageView alloc] init];
    head.image = [UIImage imageNamed:@"icon_tx2"];
    head.contentMode = UIViewContentModeScaleAspectFit;
    [self.contentView addSubview:head];
    head.layer.masksToBounds = YES;
    head.layer.cornerRadius = 15;
    self.headIamge = head;
    
    UIImageView *appImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tag_phone"]];
    appImage.contentMode = UIViewContentModeScaleAspectFit;
    [self.contentView addSubview:appImage];
    self.appImage = appImage;
    
    TYMLabel *lab = [TYMLabel lb_text:@"sdfsfs" font:Font_Medium(15) color:rgba(74, 74, 74)];
    [self.contentView addSubview:lab];
    self.mobile  = lab;
    
    UIImageView *image = [[UIImageView alloc] init];
    image.image = [UIImage imageNamed:@"icon_ok1"];
    [self.contentView addSubview:image];
    self.righImage = image;
    
    [self.headIamge mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.equalTo(@(30));
        make.centerY.equalTo(self.contentView);
        make.left.mas_equalTo(15);
    }];
    
    [self.appImage mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.mas_equalTo(self.headIamge.mas_right).offset(3);
        make.bottom.mas_equalTo(self.headIamge.mas_bottom).offset(3);
        make.height.width.mas_equalTo(17);
    }];
    
    [self.mobile mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.headIamge.mas_right).offset(10);
        make.centerY.equalTo(self.headIamge);
        
    }];
    
    [self.righImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.headIamge);
        make.width.height.equalTo(@(20));
        make.right.mas_equalTo(@(-15));
    }];
    
}

-(void)setUserModel:(UserModel *)userModel{
    _userModel = userModel;
    _mobile.text = userModel.nickname?userModel.nickname:userModel.mobile;
    
    if (userModel.headImgUrl) {
        [self.headIamge yp_setImageUlr:[userModel getEquipmentImage] placeHolder:@"icon_tx2"];
    }
    if(userModel.isSelected){
        _righImage.image = [UIImage imageNamed:@"icon_home12"];
    }else{
        _righImage.image = [UIImage imageNamed:@"icon_home13"];
    }
    
    if (userModel.type == 1) {
        self.appImage.hidden = NO;
    }else{
        self.appImage.hidden = YES;
    }
}

+(NSString*)identifier{
    return @"AddRoomCell";
}

+(CGFloat)cellForHeight{
    return 54;
}

@end
